package com.example.peibei.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.dingtao.common.bean.DashData;
import com.dingtao.common.bean.Wallet;
import com.dingtao.common.core.DataCall;
import com.dingtao.common.core.WDActivity;
import com.dingtao.common.core.exception.ApiException;
import com.dingtao.common.util.SPUtils;
import com.dingtao.common.util.UIUtils;
import com.example.peibei.R;
import com.example.peibei.base.SpConstant;
import com.example.peibei.service.presenter.DashDataPresenter;
import com.example.peibei.service.presenter.MyWalletPresenter;

import butterknife.BindView;
import butterknife.OnClick;

public class MyWelletActivity extends WDActivity {

    @BindView(R.id.tv_my_money)
    TextView tv_my_money;

    private double balance;
    private SPUtils spUtils;
    private String token;
    private long mid;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_wallet;
    }

    @Override
    protected void initView() {
        spUtils = new SPUtils(MyWelletActivity.this, SpConstant.USER_TOKEN);
        token = spUtils.getString(SpConstant.USER_TOKEN);
        mid = spUtils.getLong(SpConstant.USER_MID);
        MyWalletPresenter myWalletPresenter = new MyWalletPresenter(new WalletCall());
        myWalletPresenter.reqeust("Bearer " + token, mid);
    }

    @OnClick(R.id.iv_back)
    public void back(){
        finish();
    }

    @OnClick(R.id.bt_withdrawal)
    public void withdrawal() {
        //提现
        intent(WithdrawalActivity.class);
    }

    @OnClick(R.id.tv_order_history)
    public void billRecord() {
        //提现
        intent(BillRecordActivity.class);
    }

    @OnClick(R.id.bt_user)
    public void used() {
        UIUtils.showToastSafe("该功能暂未开通");
    }

    class WalletCall implements DataCall<Wallet> {

        @Override
        public void success(Wallet data, Object... args) {
            tv_my_money.setText(""+data.getBalance());
        }

        @Override
        public void fail(ApiException e, Object... args) {
//            UIUtils.showToastSafe(e.getDisplayMessage());
        }
    }

    @Override
    protected void destoryData() {

    }
}
